import React from 'react';
import './index.less';
import { Button } from 'antd-mobile';
// import { useHistory } from 'react-router-dom';
import Tabbar from '../../components/tabbar';
import Title from '../../components/title';
import { getHomeButtonlist } from '../../config/routeConfig';
import { i18n } from '../../utils/language';

function Home(props: any) {
  console.log('home props===>', props);
  const buttonList = getHomeButtonlist();
  // let history = useHistory();//useHistory()等同于props.history
  function goTopage(item: any) {
    props.history.push(`/${item.path.split('/')[1]}/${item.name}`);
  }
  return (
    <div className='home'>
      <Title title={i18n.t('shouye')} />
      {buttonList.map((item, index) => {
        return (
          <Button color='primary' key={index} size='large' onClick={() => goTopage(item)}>
            {item.name}
          </Button>
        );
      })}
      <Tabbar currentIndex={0} />
    </div>
  );
}
export default Home;
